package homeworkplus.day03;

import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.Date;
import java.util.Scanner;

/**
 * 输入某人生日，格式为"yyyy-MM-dd"，输出到现在为止经过了多少周。
 *
 * @author Xiloer
 */
public class Test03 {
    public static void main(String[] args) throws ParseException {
        Scanner scanner = new Scanner(System.in);
        System.out.print("请输入生日：");
        String birStr = scanner.nextLine();
        //将输入的字符串转化成Date类型
        SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd");
        Date birDate = sdf.parse(birStr);
        //获取当前时间时间
        Date now = new Date();
        //计算相差时间
        long time = now.getTime() - birDate.getTime();
        time /= (1000 * 60 * 60 * 24 * 7);
        System.out.println("经过了：" + time + "周");
    }
}
